
#ifndef __COLOR_H__
#define __COLOR_H__

#include <iostream>
#include "vec3.hh"

using std::sqrt;

void write_color(std::ostream& out, color pixel, int samples_per_pixel) { 
	auto r = pixel.x();
	auto g = pixel.y();
	auto b = pixel.z();

	auto scale = 1.0 / samples_per_pixel;
	r = sqrt(r * scale); g = sqrt(g * scale); b = sqrt(b * scale);

	out << static_cast<int>(256 * clamp(r, 0.0, 0.999)) << " " 
		<< static_cast<int>(256 * clamp(g, 0.0, 0.999)) << " "
		<< static_cast<int>(256 * clamp(b, 0.0, 0.999)) << "\n";
}

#endif
